<template>
	<view class="bim"><iframe :src="Src" :update-title="false" class="bim-view"  @message="getMessage"></iframe></view>
</template>
<script>
import { BimConfigu } from '@/api/sample/index';
import {bimUrl} from '../../common/urlConfig.js'
export default {
	data() {
		return {
			BimId: '',
			Src: '',
			marks:[]
		};
	},
	onReady() {
		this.handleBimcx();
	},
	methods: {
		getMessage(e) {
			this.marks=e.detail.data[0].marks
			console.log(this.marks,1111111111111,e)
		},
		async handleBimcx() {
			const row = await BimConfigu();
			this.BimId = row.data.path;
			let token = uni.getStorageSync('token')
			let projectInfo = uni.getStorageSync('projectInfo').id
			if(!this.BimId.includes("http://")){
				this.Src = `${bimUrl}/outer/indexView?token=${token}&projectId=${projectInfo}&Bim=${this.BimId}`
			}else{
				this.Src = `${this.BimId}&punctuation=1&${Date.parse(new Date())}`
			}
		},
		/* 按钮 */
		onNavigationBarButtonTap(e) {
			//如果有数据
			if (this.marks) {
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2]; //上一个页面
				prevPage.$vm.getBimView(this.marks);
				uni.navigateBack({ delta: 1 });
			}
		}
	}
};
</script>
<style lang="scss" scoped>
.bim {
	position: relative;
	width: 100%;
	height: 100%;
	background-color: rgb(182, 181, 181);
	.bim-view {
		width: 100vw;
		height: 100vh;
	}
}
</style>
